/*
 * @Author: JohnYang
 * @Date: 2020-10-24 17:37:30
 * @LastEditors: JohnYang
 * @LastEditTime: 2020-11-07 13:20:04
 */

import Vue from 'vue'
import Component from 'vue-class-component'
import { Prop } from 'vue-property-decorator'

@Component({
  name: 'RadioGroup',
})
export default class RadioGroup extends Vue {
  @Prop({
    required: true,
  })
  value

  render(h) {
    var { style, ...rest } = this.$attrs
    return (
      <el-radio-group
        {...{
          props: {
            ...rest,
            value: this.value,
          },
          attrs: {
            ...rest,
          },
          on: {
            ...this.$listeners,
            input: (val) => {
              this.$emit('input', val)
            },
          },
          scopedSlots: {
            ...this.$scopedSlots,
          },
        }}
      >
        {rest.options.map((item) => {
          return <el-radio label={item.value}>{item.label}</el-radio>
        })}
      </el-radio-group>
    )
  }
}
